package com.twosnail.frame.controller;

import com.jfinal.core.Controller;
import com.jfinal.log.Logger;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.twosnail.frame.model.WxUser;
import org.apache.shiro.authz.annotation.RequiresPermissions;

/**
 * Created by yangcs on 2017/7/21.
 */
public class WxUserController extends Controller {
    private Logger logger = Logger.getLogger(IdentifyingCodeController.class) ;

    @RequiresPermissions("WxUserController")
    public void index(){
        try {
            Integer pageNum = getParaToInt( "pageNum" ) ;
            Integer numPerPage = getParaToInt( "numPerPage" ) ;
            String keyWord = getPara("keyWord") ;
            numPerPage = ( numPerPage == null || numPerPage == 0 ) ? 5 : numPerPage;
            pageNum = pageNum == null ? 1 : pageNum;
            Page<Record> list = WxUser.me.getAllUser(pageNum,numPerPage,keyWord);
            setAttr( "list", list );
            setAttr( "keyWord", keyWord );
        } catch (Exception e) {
            this.logger.warn( "用户列表信息，初始化失败！" , e );
        }
        render( "wx_list.html" );
    }
}
